package ioperations;

import Book.BookList;

import java.util.Scanner;

public class Borrow implements Ioperation{
    @Override
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入书名：");
        String name = scanner.nextLine();
        for (int i = 0; i < bookList.Size; i++) {
            if(name.compareTo(bookList.books[i].getName()) == 0 ){
                if(bookList.books[i].isIsborrow() == false){
                    bookList.books[i].setIsborrow(true);
                    System.out.println("图书借阅成功！");
                    return;
                }
                else{
                    System.out.println("该图书已经被借阅！");
                    return;
                }
            }
        }
        System.out.println("没有找到这本书！");
    }
}
